<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAttachmentsTable extends Migration
{

    protected $tableName = 'attachments';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('附件名称');
            $table->string('uri')->comment('附件OSS地址');
            $table->string('ext')->comment('附件后缀');
            $table->integer('size')->comment('附件大小，单位为byte');
            $table->json('properties')->default(null)->comment('附件其他属性');
            $table->unsignedTinyInteger('type')->comment('附件类型，0图片，1音频，2视频');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '附件表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
